home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 11
/
FM Towns Free Software Collection 11.iso
/
t_os
/
tool
/
morse
/
morse.bas
next >
Wrap
BASIC Source File
|
1995-08-12
|
5KB
|
201 lines
10 SCREEN 0
20 CLS
30 SH=20
40 GOSUB 920
50 L=200
60 C=0
70 CC$=""
80 PC$=""
90 LIN=0
100 MIC=1
110 BC=0
120 S=0
130 K=2
140 AW=0
150 OUT &H04E8,0
160 OUT &H04E1,8
170 OUT &H04E0,&H3F
180 OUT &H04E1,9
190 OUT &H04E0,&H3F
200 OUT &H04E3,14
210 OUT &H04E2,&H3F
220 F=0
230 CHR%=0
240 WHILE S<SH AND BC<L*7
250 BC=BC+1
260 Y=ABS(INP(&H04E7)-128)
270 LINE(320,8)-(340,8),PSET,0
280 LINE(320,8)-(320+ABS(Y)/128*20,8),PSET,4
290 IF Y>X THEN S=Y:X=(Y*3+X)/4 ELSE S=X:X=(Y+X*3)/4
300 IF PTRIG(2)=1 THEN BEEP 1 ELSE BEEP 0
310 WEND
320 IF F>=8 THEN
330 PC$=CC$
340 CC$=T$(CHR%,AW)
350 PRINT CC$;
360 F=0
370 CHR%=0
380 IF CC$="[ワブン]" THEN
385 AW=0
390 GOSUB 1310
400 ELSE IF CC$="[オウブン]" THEN
405 AW=1
410 GOSUB 1310
420 ENDIF
430 GOTO 730
440 ENDIF
450 IF BC<5 THEN C=C+BC:GOTO 810
460 IF C<L*K THEN
470 CHR%=3^F+CHR%:L=(L+C)/2
480 ELSE
490 CHR%=2*(3^F)+CHR%:L=(L+C/3)/2
500 ENDIF
510 IF BC<L*K THEN
520 F=F+1
530 GOTO 800
540 ELSE IF BC<L*4 THEN
550 PC$=CC$
560 CC$=T$(CHR%,AW)
570 PRINT CC$;
580 F=0
590 CHR%=0
591 IF CC$="[ホレ]" THEN
592 AW=0
593 GOSUB 1310
594 ELSE IF CC$="[ラタ]" THEN
595 AW=1
596 GOSUB 1310
597 ENDIF
600 GOTO 800
610 ELSE
620 PC$=CC$
630 CC$=" "
640 PRINT T$(CHR%,AW);CC$;
650 F=0
660 IF T$(CHR%,AW)="K" THEN
670 IF PC$=" " THEN PRINT
691 ELSE IF T$(CHR%,AW)="[ホレ]" THEN
692 AW=0
693 GOSUB 1310
694 ELSE IF T$(CHR%,AW)="[ラタ]" THEN
695 AW=1
696 GOSUB 1310
700 ENDIF
710 CHR%=0
720 ENDIF
730 WHILE S<SH
740 Y=ABS(INP(&H04E7)-128)
750 LINE(320,8)-(340,8),PSET,0
760 LINE(320,8)-(320+ABS(Y)/128*20,8),PSET,4
770 IF Y>X THEN S=Y:X=(Y*3+X)/4 ELSE S=X:X=(Y+X*3)/4
780 IF PTRIG(2)=1 THEN BEEP 1 ELSE BEEP 0
790 WEND
800 C=0
810 BC=0
820 WHILE S>=SH
830 C=C+1
840 Y=ABS(INP(&H04E7)-128)
850 LINE(320,8)-(340,8),PSET,0
860 LINE(320,8)-(320+ABS(Y)/128*20,8),PSET,4
870 IF Y>X THEN S=Y:X=(Y*3+X)/4 ELSE S=X:X=(Y+X*3)/4
880 IF PTRIG(2)=1 THEN BEEP 1 ELSE BEEP 0
890 WEND
900 IF C<3 THEN C=0:GOTO 730
910 GOTO 240
920 PRINT "Now preparing."
930 DIM T$(6561,1)
940 FOR I=0 TO 6561
950 FOR J=0 TO 1
960 T$(I,J)="$"
970 NEXT J
980 NEXT I
990 OPEN "I",#1,"morse.dat"
1000 FOR AW=0 TO 1
1010 INPUT#1,C$,CODE$
1020 WHILE C$<>"@@@"
1030 CODEN=0
1040 LC=LEN(CODE$)
1050 FOR I=0 TO LC-1
1060 IF "."=RIGHT$(LEFT$(CODE$,I+1),1) THEN N=1 ELSE N=2
1070 CODEN=N*(3^I)+CODEN
1080 NEXT I
1090 T$(CODEN,AW)=C$
1100 INPUT#1,C$,CODE$
1110 WEND
1120 NEXT AW
1130 CLOSE#1
1140 CONSOLE 1,24,0
1150 LOCATE 0,0,0:PRINT "文字(PF1):欧文 閾値(PF4 0<->10 PF5):";INT(SH/128*10);" MIC(PF6):ON LINE(PF7):OFF 終了(PF9)"
1160 LINE(320+SH/128*20,7)-(320+SH/128*20,9),PSET,7
1170 LOCATE 0,1
1180 ON KEY(1) GOSUB 1310
1190 ON KEY(4) GOSUB 1410
1200 ON KEY(5) GOSUB 1480
1210 ON KEY(6) GOSUB 1550
1220 ON KEY(7) GOSUB 1690
1230 ON KEY(9) GOSUB 1870
1240 KEY(1) ON
1250 KEY(4) ON
1260 KEY(5) ON
1270 KEY(6) ON
1280 KEY(7) ON
1290 KEY(9) ON
1300 RETURN
1310 XX=POS(0):YY=CSRLIN
1320 IF AW=0 THEN
1330 AW=1
1340 LOCATE 10,0,0:PRINT "和文"
1350 ELSE
1360 AW=0
1370 LOCATE 10,0,0:PRINT "欧文"
1380 ENDIF
1390 LOCATE XX,YY
1400 RETURN
1410 XX=POS(0):YY=CSRLIN
1420 LINE(320+SH/128*20,7)-(320+SH/128*20,9),PSET,0
1430 SH=SH-1:IF SH<=0 THEN SH=0
1440 LOCATE 36,0,0:PRINT INT(SH/128*10);" "
1450 LOCATE XX,YY
1460 LINE(320+SH/128*20,7)-(320+SH/128*20,9),PSET,7
1470 RETURN
1480 XX=POS(0):YY=CSRLIN
1490 LINE(320+SH/128*20,7)-(320+SH/128*20,9),PSET,0
1500 SH=SH+1:IF SH>=128 THEN SH=128
1510 LOCATE 36,0,0:PRINT INT(SH/128*10);" "
1520 LOCATE XX,YY
1530 LINE(320+SH/128*20,7)-(320+SH/128*20,9),PSET,7
1540 RETURN
1550 XX=POS(0):YY=CSRLIN
1560 IF MIC=1 THEN
1570 OUT &H04E3,10
1580 OUT &H04E2,&H3F
1590 MIC=0
1600 LOCATE 53,0,0:PRINT "OFF"
1610 ELSE
1620 OUT &H04E3,14
1630 OUT &H04E2,&H3F
1640 MIC=1
1650 LOCATE 53,0,0:PRINT "ON "
1660 ENDIF
1670 LOCATE XX,YY
1680 RETURN
1690 XX=POS(0):YY=CSRLIN
1700 IF LIN=1 THEN
1710 OUT &H04E1,8
1720 OUT &H04E0,&H3F
1730 OUT &H04E1,9
1740 OUT &H04E0,&H3F
1750 LIN=0
1760 LOCATE 67,0,0:PRINT "OFF"
1770 ELSE
1780 OUT &H04E1,12
1790 OUT &H04E0,&H3F
1800 OUT &H04E1,13
1810 OUT &H04E0,&H3F
1820 LIN=1
1830 LOCATE 67,0,0:PRINT "ON "
1840 ENDIF
1850 LOCATE XX,YY
1860 RETURN
1870 END